<?php
set_time_limit(0);

/**
 * @author   1054229380@qq.com
 * @since    2017-7-3
 * @desc     公共方法
 * */
class constant
{
    /**
     * @return mixed
     *
     * 获取基本设置
     */
    public static function getBaseSet()
    {
        $sql = "select voteStatus,checkStatus,voteDesc,backMusic from vote_baseset";
        $sqlList = main::getArrayBySql($sql);
        return $sqlList[0];
    }

    /**
     * @param $url
     *
     * 发送get请求
     */
    public static function httpGet($url)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "$url");
        curl_setopt($ch, CURLOPT_TIMEOUT, 2);
        curl_setopt($ch, CURLOPT_HEADER, 1); //如果设为0，则不使用header
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec($ch);
        curl_close($ch);
    }

    /**
     * @param $url
     * @param $postArr
     * @return mixed
     *
     * 发送post请求
     */
    public static function httpPost($url, $postArr)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postArr);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_USERAGENT, "jb51.net's CURL Example beta");
        $data = curl_exec($ch);
        curl_close($ch);
        return $data;
    }

    /**
     * @return string
     *
     * 获取微信信息
     */
    public static function getWebCatInfo()
    {
        $sql = "select appId,appSecret,tradeTemplateId,addTemplateId,rechargeTemplateId,levelTemplateId,integralTemplateId,giftTemplateId,startTemplateId,endTemplateId from lf_wechat_setting";
        $sqlList = main::getArrayBySql($sql);
        if (empty($sqlList)) {
            return "";
        } else {
            return $sqlList[0];
        }
    }

}

?>